package com.nulldev.util.uri;

import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;

import com.nulldev.util.logging.LoggerFactory;

@Deprecated
/**
 * Merging with URIUtil 2.0
 * @author null
 */
public class ProxyUtil {
	
	static {
		LoggerFactory.getLogger(true, true).error("ProxyUtil is marked for removal, ProxyUtil has been replaced with URIUtil2.ProxyUtil.");
	}

	@Deprecated
	private static boolean testProxy(final String proxyIP, final int proxyPORT, final String uri) throws Exception {
		boolean result = false;
		final String url = uri;
	    final URL obj = new URL(url);
	    final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyIP, proxyPORT));
	    final HttpURLConnection con = (HttpURLConnection) obj.openConnection(proxy);
	    //con.setRequestMethod("GET");
	    //con.setRequestProperty("User-Agent", "Mozilla/5.0");

	    con.setConnectTimeout(800);
	    con.setReadTimeout(800);

	    con.connect();

	    int response = con.getResponseCode();

	    if (response == 200) {
	    	result = true;
	    } else {
	    	result = false;
	    }

	    con.disconnect();
	    return result;
	}
}
